<template>
  	<div id="liveRoomIntroduct">
  		<header>
  			<i @click="goBack()"></i>
  			<div>直播间简介</div>
  		</header>
  		<div class="border-8"></div>
  		<div class="liveRoomIntroduct">
	  		<textarea placeholder="请输入直播间简介" v-model="obj.content"></textarea>
  		</div>
  		<a class="sureBtn" @click='save'>
			保 存	
		</a>
	</div>
</template>
<script>
	export default {
		data() {
			return {
                status: '', //add | edit
                obj: {
                    id: localStorage.getItem("loginMobile"),
                    content: '',
                }
			
			}
		},
		components: {
			
		},
		methods: {
			goBack() {
				this.$router.back();
            },
            init() {
                if(this.obj.id) {
                    this.$api.get(this.$api.baseURLSchool,"select_cid/live_room/"+this.obj.id,{},r => {
                        if(r.data.ret == 1) {
                            this.status = 'edit';
                            this.obj = r.data.info;
                        } else {
                            this.status = 'add';
                        }
                    },err => {
                        console.log(err);
                    })
                }
            },
            save() {
                if(!this.obj.id) {
                    this.$utils._toast("请登录");  
                    return false; 
                }
                if(!this.obj.content) {
                    this.$utils._toast("请输入简介");  
                    return false; 
                }
                this.$api.post(this.$api.baseURLSchool,"update_live_room/"+this.status,this.obj,r => {
                    if(r.data.ret == 1) {
                        this.$utils._toast("保存成功");
                        setTimeout(() => {
                            this.$router.back();
                        },300);
                    }
                },err => {
                    console.log(err);
                })
            }
			
		},
		created() {
            this.init();
		}
	}
</script>
<style lang="scss" scoped>
	
</style>
